<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="common.gFunction" %>
<%@ page import="demiBoard.DemiBoardFunction" %>


<%ArrayList boardList =gFunction.getNotNullArray((ArrayList)request.getAttribute("boardList"),new ArrayList()); %>
<%HashMap  boardProperMap =(HashMap)request.getAttribute("boardProperMap");%>
<%String numOfPage =gFunction.getNotNull((String)request.getAttribute("numOfPage"),"1"); %>
<%
int numOfPage_i=Integer.parseInt(numOfPage);
int boardPerPage=Integer.parseInt((String)boardProperMap.get("cBoardPerPageNum"));
int curPage=Integer.parseInt(gFunction.getNotNull((String)request.getParameter("reqBoardPage"),"1"));
%>

<script type="text/javascript">

	function readPost(postId){
		var formBoardList = jQuery("#formBoardList");
		formBoardList.children(".reqFunc").attr("value","boardReadPost");
		formBoardList.children(".reqPostId").attr("value",postId);
		ajaxSend('/boardPage',aMainBodyRight,'post','formBoardList');
	}
	function goPrevPagePage(){
		var formBoardList = jQuery("#formBoardList");
		
		var reqBoardPagePage = formBoardList.children(".reqBoardPagePage").attr("value");
		formBoardList.children(".reqBoardPagePage").attr("value",parseInt(reqBoardPagePage)-1);
		
		var prevPageNum=parseInt((parseInt(reqBoardPagePage)-2)*<%=boardPerPage%>)+1;
		
		formBoardList.children(".reqBoardPage").attr("value",prevPageNum);
		formBoardList.children(".reqFunc").attr("value","showBoard");
		
		ajaxSend('/boardPage',aMainBodyRight,'post','formBoardList','mainBodyRight');
	}
	function goNextPagePage(){
		var formBoardList = jQuery("#formBoardList");
		var reqBoardPagePage = formBoardList.children(".reqBoardPagePage").attr("value");
		formBoardList.children(".reqBoardPagePage").attr("value",parseInt(reqBoardPagePage)+1);
		
		var nextPageNum=parseInt(reqBoardPagePage*<%=boardPerPage%>)+1;
		
		formBoardList.children(".reqBoardPage").attr("value",nextPageNum);
		formBoardList.children(".reqFunc").attr("value","showBoard");
		ajaxSend('/boardPage',aMainBodyRight,'post','formBoardList','mainBodyRight');
	}
	
	function goTargetPage(boardId){
		var formBoardList = jQuery("#formBoardList");
		formBoardList.children(".reqBoardPage").attr("value",boardId);
		formBoardList.children(".reqFunc").attr("value","showBoard");
		ajaxSend('/boardPage',aMainBodyRight,'post','formBoardList','mainBodyRight');
	}
	function goBoardPost(){
		var formBoardList = jQuery("#formBoardList");
		formBoardList.children(".reqFunc").attr("value","gotoPostBoard");
		ajaxSend('/boardPage',aMainBodyRight,'post','formBoardList','mainBodyRight');
	}
</script>
<div id="demiBoardList">
	<dh><div class="fLeft">글번호</div><div class="fLeft">제목</div><div class="fLeft">날짜</div><div class="fLeft">부모</div><div class="clear"></div></dh>
	<div id="soldierBoardItems">
		<%=DemiBoardFunction.getBoardTag(boardList)%>
	</div>
	<div class="clear"></div>
	<div>
		<span>총 글수<%=(String)request.getAttribute("numOfPost")%></span>
		<%=DemiBoardFunction.getBoardNaviTag(numOfPage_i,boardPerPage,curPage)%>
	</div>
	<div class="clear"></div>
	<a href="#" class="button" onclick="goBoardPost();">글쓰기</a>
	
	
	<form id="formBoardList">
		<input type="hidden"  name="reqFunc" class ="reqFunc" value=""/>
		<%@include file="./demiBoardNeed.jsp" %>
	</form>

</div>